/**
 * Created by zhanshen886 on 2019/1/31.
 */
var userId=getQueryString('UserID');
var name="";
var mobile="";
var proCode="";
var cityCode="";
var areaCode="";
var address="";

function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = decodeURI(window.location.search).substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}

$(function(){

    $("#close_id").click(function(){
       window.history.go(-1);

    });
    $("#btn_save_id").click(function(){
         name=$("#input_id1").val();
 mobile=$("#input_id2").val();
       proCode=$("#input_id3").val();

       address=$("#input_id4").val();
        console.log(areaCode);
      if(null==userId){
          popup.pop({content:"userId不能为空！"});
          return false;
      }
        if(name==""){
            popup.pop({content:"姓名不能为空！"});
            return false;
        }
        if(mobile==""){
            popup.pop({content:"手机号码不能为空！"});
            return false;
        }
if($("#input_id3").val()==""){
    popup.pop({content:"所在地区不能为空！"});
    return false;
}
        if(address==""){
            popup.pop({content:"详细地址不能为空！"});
            return false;
        }

show_loading();
        HttpInterface(1);

    });


    function  HttpInterface(inter){
      if(inter==1){
          $.post("http://112.29.169.12:8090/portal-wap/noLogin/internetTv_addressManager.msp", {
              isTest:"wondertek",
              uuid:"123",
              userId:userId,
              name:name,
              mobile:mobile,
              proCode:proCode+cityCode+areaCode,
              cityCode:"",
              areaCode:"",
              address:address
          }, function (data) {
              console.log(data.retdata);
              stop_loading();
              var retcode = data.retcode;
              var retmsg=data.retmsg;
              if (retcode == 0) {
                  popup.pop({content:retmsg});
                  window.opener=null;
                  window.open('', '_self');
                  window.close();
              }else{

                  popup.pop({content:retmsg});
              }
          }, "json")
      }

    }

});
